import numpy as np
import matplotlib.pyplot as plt

# Defining the functions as described
def func_f(x):
    return x**8 - 8*x**7 + 28*x**6 - 56*x**5 + 70*x**4 - 56*x**3 + 28*x**2 - 8*x + 1

def func_g(x):
    return (((((((x - 8) * x + 28) * x - 56) * x + 70) * x - 56) * x + 28) * x - 8) * x + 1

def func_h(x):
    return (x - 1)**8

# Generating 101 equally spaced points between 0.99 and 1.01
x_values = np.linspace(0.99, 1.01, 101)

# Calculating values for each function
f_values = func_f(x_values)
g_values = func_g(x_values)
h_values = func_h(x_values)

# Plotting the functions
plt.figure(figsize=(10, 6))
plt.plot(x_values, f_values, label='f(x)', marker='o')
plt.plot(x_values, g_values, label='g(x)', marker='x')
plt.plot(x_values, h_values, label='h(x)', marker='^')
plt.xlabel('x')
plt.ylabel('Function values')
plt.title('Comparison of Functions near 1.0')
plt.legend()
plt.grid(True)
plt.show()